<?php

namespace App\Traits\Relation;

use App\Models\Company;
use App\Models\Project;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

/**
 * 定义合作模型关联关系
 *
 * Trait ConsociationRelation
 * @package App\Traits\Relation
 * Date: 24/04/2018
 * @author George
 */
trait ConsociationRelation
{
    /**
     * 获取发起合作公司
     *
     * Date: 11/04/2018
     * @author George
     * @return BelongsTo
     */
    public function initiator()
    {
        return $this->belongsTo(Company::class, 'initiator', 'id');
    }

    /**
     * 获取合作公司
     *
     * Date: 11/04/2018
     * @author George
     * @return BelongsTo
     */
    public function partner()
    {
        return $this->belongsTo(Company::class, 'partner', 'id');
    }

	/**
	 * 获取合作信息关联的项目
	 *
	 * Date: 24/04/2018
	 * @author George
	 * @return BelongsTo
	 */
    public function project()
    {
        return $this->belongsTo(Project::class, 'project_id', 'id');
    }
}
